#include<stdio.h>
#include<conio.h>
#define ta 1
#define khach 0
#define ok 2
int thang(int thangnha, int thuanha,int thangkhach,int thuakhach){
    if(thangnha+thangkhach>thuanha+thuakhach)return ta;
    else if(thangnha+thangkhach<thuanha+thuakhach) return khach;
    else{
        if(thangkhach>thuanha)return ta;
        else if(thangkhach<thuanha)return khach;
    }
    return ok;
}
int main(){
    int t,i,j,x,y,min,max;
    char a,c;
    scanf("%d",&t);
    for(i=1;i<=t;i++){
        if(i>1)printf("\n");
        for(j=1;j<=28;j++)scanf("%c",&c);
        for(j=2;j<=18;j++)scanf("%c",&a);scanf("%d",&x);
        for(j=1;j<=21;j++)scanf("%c",&a);scanf("%d",&y);
        for(j=1;j<=7;j++)scanf("%c",&a);
        
        
        if(c=='h'){
            for(min=0;min<=30;min++)
                if(thang(x,y,min,0)!=khach)break;
            for(max=30;max>=0;max--)
                if(thang(x,y,max,30)!=ta)break;
             printf("%d %d",min,max);   
        }else{
            for(min=0;min<=30;min++)
                if(thang(min,0,x,y)!=khach)break;
            for(max=30;max>=0;max--)
                if(thang(max,30,x,y)!=ta)break;
             printf("%d %d",min,max);   
        }
    }
    getch();
    return 0;
}
